pub fn convert_base(num_str: &str, to_base: u32) -> String {
    
    let mut num = 0 as u32;
    let mut base_n = 1 as u32;
    // 待转换的字符集合
    let chars = "0123456789abcdef".chars().collect::<Vec<_>>();

    // 先提取原始数字符串以及基数
    if let Some((num_s, base_str)) = num_str.rsplit_once('(') {
        if let Some(base_str) = base_str.strip_suffix(')') {
            if let Ok(base) = base_str.parse::<u32>() {
                
                // 将原始数转换为十进制数
                for c in num_s.chars().rev() {
                
                    if c >= 'a' && c <= 'f' {
                        num += (c as u32 - 87) * base_n;
                    } else if c >= 'A' && c <= 'F' {
                        num += (c as u32 - 55) * base_n;
                    } else if c >= '0' && c <= '9' {
                        num += (c as u32 - 48) * base_n;
                    } else {
                        panic!("Invalid input format or base");
                    }
                    
                    base_n *= base;
                }

                if num == 0 {
                    return "0".to_string();
                }

                // 将十进制数转换为目标基数
                let mut result = String::new();
                while num > 0 {
                    let remainder = num % to_base;
                    num = num / to_base;
                    // 将余数转换为字符并插入到结果字符串的开头
                    result = chars[remainder as usize].to_string() + &result;
                    
                }

                return result;
            }
        }
    }

    panic!("Invalid input format or base");

}
